package com.ce.pms.log4ce;

import java.util.Map;

import org.aspectj.lang.JoinPoint;

import com.ce.component.log4ce.aop.constructor.support.AbstractBizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.BizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.OriginalObjectHolder;
import com.ce.component.log4ce.aop.parser.BizLogParser;
import com.ce.pms.customer.model.IndividualDO;
import com.ce.pms.customer.vo.IndividualVO;
import com.ce.pms.customer.vo.MemberVO;
import com.ce.util.BlankUtil;

public class MemberEditHandler extends AbstractBizDescriptionHandler implements BizDescriptionHandler
{
	private Log4ceHelper log4ceHelper = Log4ceHelper.getInstance();
	@Override
	public Map<String, Object> getNamedParametersMap(JoinPoint joinPoint, Object returnVlaue, BizLogParser logParser) {

		Map<String,Object> map = logParser.getLogArguments(joinPoint);

		IndividualVO oldMember = (IndividualVO)OriginalObjectHolder.ORIGINAL_OBJECTS.get().get("oldMemberInfo");
		MemberVO ownerVo = (MemberVO)map.get("membervo");
		String oldCustomerName = ownerVo.getOwnerName();//log4ceHelper.getCustomerName(ownerVo.getOwnerId());
		String oldHouseNumber = ownerVo.getOldHouseNumber();//log4ceHelper.getHouseNumber(ownerVo.getHouseId());

		map.put("oldCustomerName", oldCustomerName);
		map.put("oldHouseNumber", oldHouseNumber);
		map.put("oldParticipantName", oldMember.getParticipantName());
		map.put("oldID_type", oldMember.getCertificateTypeName());
		map.put("oldIdNumber", oldMember.getCertificateNo());
		map.put("oldTelephone", oldMember.getTelephone());

		IndividualDO individual = (IndividualDO)returnVlaue;
		if(!BlankUtil.isBlank(individual)){
			map.put("participantName", individual.getParticipantName());
			map.put("ID_type", individual.getIdType().getIdTypeName());
			map.put("idNumber", individual.getIdNumber());
			map.put("telephone", individual.getTelephone());
		}
		String customerName = log4ceHelper.getCustomerName(ownerVo.getOwnerId());
		String houseNumber = log4ceHelper.getHouseNumber(ownerVo.getHouseId());
		map.put("customerName", customerName);
		map.put("houseNumber", houseNumber);
		map.putAll(logParser.getLogStaticContents(joinPoint));
		return map;
	}

}